<template>
  <div class="home">
    home
    <button @click="add">改变state</button>
    <p>{{this.$store.state.num}}</p>
    <p>
      <router-link to="/city">
        <button>{{this.$store.state.city}}</button>
      </router-link>
    </p>
  </div>
</template>

<script>
export default {
  name: "Home",
  data() {
    return {};
  },
  methods:{
    add(){
      this.$store.dispatch("addNum")
    }
  },
  beforeRouteEnter(to){
    console.log(to);
  }
};
</script>
